﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>码云卡后台管理登录平台欢迎你</title>
    <link href="/Content/admin/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="/Content/admin/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
    <link href="/Content/admin/dist/css/sb-admin-2.css" rel="stylesheet">
    <link href="/Content/admin/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="/Content/alertify-js/css/alertify.css" rel="stylesheet" />
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <div class="login-panel panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">码云卡 - 请登录</h3>
                    </div>
                    <div class="panel-body">
                        <form role="form">
                            <fieldset>
                                <div class="form-group">
                                    <input id="UserName" class="form-control" placeholder="用户名" type="text" autofocus />
                                </div>
                                <div class="form-group">
                                    <input id="Pwd" class="form-control" placeholder="密码" type="password"/>
                                </div>
                                <a id="btnLogin" href="javascript:;" class="btn btn-lg btn-success btn-block">登 录</a>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/Content/admin/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="/Content/alertify-js/js/alertify.js"></script>
    <script>
        $(function () {
            $("body").keydown(function (e) {
                if (e.keyCode == 13) {
                    $('#btnLogin').click();
                }
            });

            $('#btnLogin').click(function () {
                var loginName = $("#UserName").val();
                var loginPwd = $("#Pwd").val();
                if (loginName.length == 0) {
                    alertify.error("登录账户不能为空");
                    return false;
                }
                if (loginPwd.length == 0) {
                    alertify.error("登录密码不能为空");
                    return false;
                }
                $("#btnLogin").attr("disabled", "disabled");
                $.ajax({
                    type: "post",
                    url: "/Login/LoginValidate",
                    data: { userName: loginName, pwd: loginPwd, w: "@ViewBag.MxWechatInfoUserId" },
                    dataType: "json",
                    success: function (data) {
                        if (!data.Status) {
                            $("#btnLogin").removeAttr("disabled");
                            alertify.error(data.Message);
                        } else {
                            $("#btnLogin").html("登 录 成 功");
                            window.location.href = "/Home/Frame";
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>